
package com.platform.modules.job.task;

import com.platform.modules.mall.service.MallCardSnService;
import com.platform.modules.mall.service.MallUserCardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 卡卷定时任务
 * couponTask为spring bean的名称
 *
 * @author
 */
@Slf4j
@Component("cardTask")
public class CardTask {
    @Resource
    private MallUserCardService userCardService;
    @Resource
    private MallCardSnService cardSnService;


    /**
     * 卡卷过期
     */
    @SuppressWarnings(value = "unused")
    public void expireCoupon() {
        log.info("--------------------------开始卡卷定时任务过期任务--------------------------");
        userCardService.expireCard();
        log.info("--------------------------结束执行卡卷定时任务任务--------------------------");
    }

    /**
     * 微信立减金卡券SN过期
     */
    @SuppressWarnings(value = "unused")
    public void expireCouponSN() {
        cardSnService.lambdaUpdate()
                .setSql("STATUS = 4 WHERE TYPE = 98 AND SUBDATE(EXPIRE_TIME,30) < NOW()")
                .update();
    }
}
